package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Demo9 {
    public static void main(String[] args) {
        try(Connection connection = DEUtil.getConnection()){
            String sql = "INSERT INTO user(username,password,nickname,age) VALUES (?,?,?,?)";
            PreparedStatement preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1,"zhangsan");
            preparedStatement.setString(2,"123456");
            preparedStatement.setString(3,"张三");
            preparedStatement.setInt(4,18);
            int num = preparedStatement.executeUpdate();
            System.out.println(num>0 ?"添加成功" : "添加失败");
        }catch (SQLException e){
            e.printStackTrace();
        }

    }
}
